package com.guigu.tms.aggregation.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.tms.aggregation.service.ITransportTripsService;
import com.guigu.tms.aggregation.service.ITransportTripsTruckDriverService;
import com.guigu.tms.aggregation.service.ITruckDriverService;
import com.guigu.tms.aggregation.service.ITruckService;
import com.guigu.tms.commons.aggregation.entity.TransportTrips;
import com.guigu.tms.commons.aggregation.entity.TransportTripsTruckDriver;
import com.guigu.tms.commons.aggregation.entity.Truck;
import com.guigu.tms.commons.aggregation.entity.TruckDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 车次信息表 前端控制器
 * </p>
 *
 * @author wj
 * @since 2022-10-21
 */
@Controller
@RequestMapping("/transportTrips")
public class TransportTripsController {
    @Autowired
    private ITransportTripsService transportTripsService;
    @Autowired
    private ITruckService truckService;
    @Autowired
    private ITruckDriverService truckDriverService;
    @Autowired
    private ITransportTripsTruckDriverService tripsTruckDriverService;

    @GetMapping("getTransportTrips")
    public List<TransportTrips> getTransportTrips(String id){
        QueryWrapper<TransportTrips> wrapper = new QueryWrapper<>();
        wrapper.eq("transport_line_id",id);
        return transportTripsService.list(wrapper);
    }

    @PostMapping("getTripsTruckDriver")
    public List<TransportTripsTruckDriver> getTripsTruckDriver(List<String> ids){
        QueryWrapper<TransportTripsTruckDriver> wrapper = new QueryWrapper<>();
        wrapper.in("transport_trips_id", ids);
        return tripsTruckDriverService.list(wrapper);
    }

    @PostMapping("getTruckByIds")
    public List<Truck> getTruckByIds(List<String> ids){
        return truckService.listByIds(ids);
    }

    @PostMapping("getTruckDriverByIds")
    public List<TruckDriver> getTruckDriverByIds(List<String> ids){
        return truckDriverService.listByIds(ids);
    }

    @PostMapping("getTransportTripsByIds")
    List<TransportTrips> getTransportTripsByIds(@RequestBody List<String> ids){
        return transportTripsService.listByIds(ids);
    }

    @GetMapping("getTransportTripsById")
    public TransportTrips getTransportTripsById(String id){
        return transportTripsService.getById(id);
    }

}
